import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
// 自定义主题色
import '@/styles/element-variables.scss'
// 配置elementUi语言
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
Vue.use(ElementUI, { locale })

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// 引入http, utils, validate, filters
import request from './api/index'
import utils from './utils/index'
import valid from './utils/validate'
import filters from './filters' // global filters
// 持载http, utils, validate方法到原型方法下
Vue.prototype.$http = request
Vue.prototype.$utils = utils
Vue.prototype.$valid = valid
// 全局注册过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// 全局中自定义按钮指令(也可注释定义局部)
// import permission from './directive/permission'
// Vue.directive('permission', permission)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
import { mockXHR } from '../mock'
if (process.env.NODE_ENV === 'production') {
  mockXHR()
}

// 打开生产环境调试工具
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
